import java.io.IOException;
import java.net.*;
import java.util.Scanner;


// 客户端
public class DataGramPacketDemo03 {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
        // 创建数据包
        InetAddress address = InetAddress.getByName("127.0.0.1");
        // 创建udp对象
        DatagramSocket socket = new DatagramSocket();
        while (true) {
            String s = scanner.next();
            DatagramPacket datagramPacket = new DatagramPacket(s.getBytes(), 0, s.getBytes().length, address, 9001);
            socket.send(datagramPacket);
            if (s.equals("88")) {
                break;
            }
        }

        if (!socket.isClosed()) {
            socket.close();
        }
    }
}
